package com.sinoglobal.ningxia.thread;

import android.os.AsyncTask;

import com.sinoglobal.ningxia.R;
import com.sinoglobal.ningxia.frame.ITask;



/**
 * @author qiwx
 * @createdate 2014-6-17 上午10:34:32
 * @Description:异步任务，可弹对话框
 */
public abstract class ItktAsyncTaskWithDialog<Params, Progress, Result> extends AsyncTask<Params, Progress, Result> implements
		ITask<Params, Progress, Result> {

	private String message = null;
	private boolean isLoadingPrompt = true; // isLoadingPrompt
	private boolean isCanceled = true;

	public ItktAsyncTaskWithDialog() {
	}

	/**
	 * @param message
	 *            提示信息
	 * @param isLoadingPrompt
	 *            是否对话框
	 * @param isCanceled
	 *            是否允许关闭
	 */
	public ItktAsyncTaskWithDialog(String message, boolean isLoadingPrompt, boolean isCanceled) {
		this.message = message;
		this.isLoadingPrompt = isLoadingPrompt;
		this.isCanceled = isCanceled;

	}

	@Override
	protected void onPreExecute() {
		if (isLoadingPrompt) {
			
		}
		super.onPreExecute();
	}

	@Override
	protected Result doInBackground(Params... params) {
		try {
			return before(params);
		} catch (Exception e) {
			e.printStackTrace();			
			cancel(false);
		}
		return null;
	}

	@Override
	protected void onPostExecute(Result result) {
		super.onPostExecute(result);
		if (isLoadingPrompt) {
			
		}
		after(result);
	}

	@Override
	protected void onCancelled() {
		super.onCancelled();
	}
}
